package wechat

import (
	"context"
	"gitee.com/Cauchy_AQ/vxopen/api/internal/svc"
	"gitee.com/Cauchy_AQ/vxopen/api/internal/types"
	"gitee.com/Cauchy_AQ/vxopen/rpc/wechat/wechat"
	"github.com/zeromicro/go-zero/core/logx"
)

type QrcodeLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewQrcodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QrcodeLogic {
	return &QrcodeLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *QrcodeLogic) Qrcode(req *types.QrcodeReq) (resp *types.QrcodeResp, err error) {
	respRpc, err := l.svcCtx.Wechat.Qrcode(l.ctx, &wechat.QRCodeReq{})
	if err != nil {
		return nil, err
	}
	return &types.QrcodeResp{Image: respRpc.Image, ImageURL: respRpc.ImageURL, Ticket: respRpc.Ticket}, nil
}
